#include <iostream>

using namespace std;


struct TreeNode {
	int val;
	struct TreeNode *left;
	struct TreeNode *right;
	TreeNode(int x) :
		val(x), left(NULL), right(NULL) {
	}
};

bool isMer(TreeNode *left, TreeNode *right)
{
	if (left == NULL) return right == NULL;
	if (right == NULL) return false;
	if (left->val != right->val) return false;
	else return isMer(left->right, right->left) && isMer(left->left, right->right);
}

bool isSymmetrical(TreeNode* pRoot)
{
	if (pRoot == NULL) return false;
	return isMer(pRoot->left, pRoot->right);
}